package com.lznAdmin.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lznAdmin.system.entity.SysUserRole;
import com.lznAdmin.system.mapper.SysUserRoleMapper;
import com.lznAdmin.system.service.SysUserRoleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @program: lznAdmin-pro
 * @description:
 * @author: lzn
 * @create: 2022-01-19 17:24
 **/
@Slf4j
@Service
public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUserRole> implements SysUserRoleService {

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Boolean roleReassignUser(List<SysUserRole> sysUserRoleList) {
        Long roleId = sysUserRoleList.get(0).getRoleId();
        Map<String, Object> role_id = new HashMap<>();
        role_id.put("role_id", roleId);
        this.removeByMap(role_id);
        return this.saveBatch(sysUserRoleList);
    }
}
